<?php


namespace app\api\controller\v29;


use app\aliyun\controller\AliyunRtc;
use app\api\controller\v2\Auth;
use app\chat\LiveMessage;
use app\common\cachemodel\live\LiveAnchorInfo;
use app\common\cachemodel\live\LiveOrderData;
use app\common\cachemodel\live\LiveRecordingInfo;
use app\common\cachemodel\live\LiveRtcRecord;
use app\common\cachemodel\ZlUserVip;
use think\Cache;

class LiveRtc extends Auth
{

    /**
     * 生成 客户端调用RTC_SDK加入房间的Token信息
     */
    public function getRtcAuth()
    {
        $liveRecordId = input('live_record_id/d', 0);
        $liveRecordingInfo = new LiveRecordingInfo();
        $liveRecordInfo = $liveRecordingInfo->getInfoById($liveRecordId);
        if ((int)$liveRecordInfo['status'] !== 1)
        {
            return show(config('code.error'), '服务异常，直播已结束');
        }
        // 获取当前直播间 连麦 信息
        $rtcRecordModel = new LiveRtcRecord();
        $nowRtcData = $rtcRecordModel->getNowRtcDataByCache($liveRecordId);
        if ($nowRtcData && (int)$nowRtcData['uid'] === $this->user['id'])
        {   // 当前有连麦信息 且 连麦用户是自己
            $result = (new AliyunRtc())->getRtcAuth($this->user['id'], $liveRecordInfo['live_id'], '');
            if (empty($result))
            {
                return show(config('code.error'), '服务异常');
            }
        } else
        {
            return show(config('code.error'), '服务异常，请稍后再试～');
        }
        return show(config('code.success'), '请求成功', $result);
    }

    /**
     * 用户申请连麦
     */
    public function requestRtc()
    {
        $liveRecordId = input('live_record_id/d', 0);
        $rtcRecordModel = new LiveRtcRecord();
        $liveRecordingInfo = new LiveRecordingInfo();

        $liveRecordInfo = $liveRecordingInfo->getInfoById($liveRecordId);

        if ((int)$liveRecordInfo['status'] !== 1)
        {   // 直播已结束  直接返回连麦关闭
            return show(config('code.error'), '当前主播未开启连麦');
        }

        // 如果已经申请了 返回申请连麦信息
        $rtcList = $rtcRecordModel->getRtcUserList($liveRecordId);
        $questionRtcNum = count($rtcList);
        if ($rtcList)
        {   // 如果已经申请了
            $uids = array_keys($rtcList);
            if (in_array($this->user['id'], $uids, false))
            {   //  如果已经申请
                $rtcId = (int)$rtcList[$this->user['id']];
                $rtcInfo = $rtcRecordModel->getInfoById($rtcId);
                switch ($rtcInfo['status'])
                {
                    case 1:
                        return show(config('code.success'), '请求成功', [
                            'rtc_id' => $rtcId,
                            'question' => $rtcInfo['question'],
                            'status' => (int)$rtcInfo['status'],
                            'tip1' => '已成功申请，请耐心等待主播响应…',
                            'tip2' => '当前' . $questionRtcNum . '人正在等待',
                        ]);
                    case 2:
                        return show(config('code.success'), '请求成功', [
                            'rtc_id' => $rtcId,
                            'question' => $rtcInfo['question'],
                            'status' => (int)$rtcInfo['status'],
                            'tip1' => '主播已向你发起连麦邀请…',
                            'tip2' => '',
                        ]);
                    case 3:
                        return show(config('code.success'), '请求成功', [
                            'rtc_id' => $rtcId,
                            'question' => $rtcInfo['question'],
                            'status' => (int)$rtcInfo['status'],
                            'tip1' => '正在与主播连线中…',
                            'tip2' => '',
                        ]);
                    default:
                }
            }
        }
        // 判断用户是否被主播直接邀请连麦
        $nowRtcData = $rtcRecordModel->getNowRtcDataByCache($liveRecordId);
        if ($nowRtcData && (int)$nowRtcData['uid'] === $this->user['id'])
        { // 当前用户被邀请连麦
            if ((int)$nowRtcData['status'] === 1)
            {
                return show(config('code.success'), '请求成功', [
                    'rtc_id' => 0,
                    'question' => '',
                    'status' => 2,
                    'tip1' => '主播已向你发起连麦邀请…',
                    'tip2' => '',
                ]);
            } else
            {
                return show(config('code.success'), '请求成功', [
                    'rtc_id' => (int)($nowRtcData['id'] ?? 0),
                    'question' => '',
                    'status' => 3,
                    'tip1' => '正在与主播连线中…',
                    'tip2' => '',
                ]);
            }
        }

        if ($this->request->isPost())
        {   // 用户进行 申请连麦
            // 获取当前 rtc开关开启状态
            $rtcSwitch = (int)(Cache::get("live:rtc_switch:{$liveRecordInfo['live_id']}:{$liveRecordId}", 0));
            if ($rtcSwitch !== 1)
            {
                return show(config('code.error'), '当前主播未开启连麦');
            }
            // 获取连麦配置信息
            $rtcConfig = (new LiveAnchorInfo())->getAnchorExtendConfig($liveRecordInfo['live_id'], 'rtc_config');
            // 是否符合申请权限
            switch ($rtcConfig['rtc_auth'])
            {
                case 2: // 本场直播下单用户
                    // 下单权限验证  是否在本场直播中下单
                    $orderUids = (new LiveOrderData())->getLiveRecordOrderUid($liveRecordId);
                    if (!$orderUids || !in_array($this->user['id'], $orderUids, false))
                    {   // 下单了的用户
                        return show(config('code.error'), '主播设置了权限，请稍后再试～');
                    }
                    break;
                case 3: // 会员用户
                    $vipLevel = (new ZlUserVip())->getUserVipLevel($this->user['id']);
                    if ($vipLevel < 1)
                    {   // 不是VIP 则返回
                        return show(config('code.error'), '主播设置了权限，请稍后再试～');
                    }
                    break;
                default:
            }
            // 判断申请人数是否已满
            if ($questionRtcNum >= $rtcConfig['rtc_max_user'])
            {
                return show(config('code.error'), '当前申请人数已满，请稍后再试～');
            }
            // 入库 申请成功
            $data = [
                'uid' => $this->user['id'],
                'live_id' => (int)$liveRecordInfo['live_id'],
                'live_record_id' => $liveRecordId,
                'type' => 1,
                'status' => 1,
                'question' => '',
                'application_time' => $this->request->time(),
            ];

            $rtcId = $rtcRecordModel->addRtc($data);

            // 向连麦用户发送消息
            LiveMessage::sendMsg(LiveMessage::who(LiveMessage::WHO_TYPE_UID, $data['live_id'], $this->user['id'])
                , LiveMessage::MSG_TYPE_RTC_STATUS, 3); // 申请中
            // 向直播间 管理员和主播 发送连麦 状态消息
            LiveMessage::sendMsg(LiveMessage::who(LiveMessage::WHO_TYPE_LIVER, $data['live_id'], $data['live_id'])
                , LiveMessage::MSG_TYPE_RTC_STATUS, 3); // 申请中

            return show(config('code.success'), '请求成功', [
                'rtc_id' => $rtcId,
                'question' => '',
                'status' => 1,
                'tip1' => '已成功申请，请耐心等待主播响应…',
                'tip2' => '当前' . ($questionRtcNum + 1) . '人正在等待',
            ]);
        } else
        {
            // 获取当前 rtc开关开启状态
            $rtcSwitch = (int)(Cache::get("live:rtc_switch:{$liveRecordInfo['live_id']}:{$liveRecordId}", 0));
            if ($rtcSwitch === 1)
            {
                // 获取连麦配置信息
                $rtcConfig = (new LiveAnchorInfo())->getAnchorExtendConfig($liveRecordInfo['live_id'], 'rtc_config');
                // 是否符合申请权限
                switch ($rtcConfig['rtc_auth'])
                {
                    case 2: // 本场直播下单用户
                        // 下单权限验证  是否在本场直播中下单
                        $orderUids = (new LiveOrderData())->getLiveRecordOrderUid($liveRecordId);
                        if (!$orderUids || !in_array($this->user['id'], $orderUids, false))
                        {   // 下单了的用户
                            // 用户未申请连麦 获取连麦信息
                            return show(config('code.success'), '请求成功', [
                                'rtc_id' => 0,
                                'question' => '',
                                'status' => 4,
                                'tip1' => "主播设置了连麦权限暂时无法申请",
                                'tip2' => '',
                            ]);
                        }
                        break;
                    case 3: // 会员用户
                        $vipLevel = (new ZlUserVip())->getUserVipLevel($this->user['id']);
                        if ($vipLevel < 1)
                        {   // 不是VIP 则返回
                            // 用户未申请连麦 获取连麦信息
                            return show(config('code.success'), '请求成功', [
                                'rtc_id' => 0,
                                'question' => '',
                                'status' => 4,
                                'tip1' => "主播设置了连麦权限暂时无法申请",
                                'tip2' => '',
                            ]);
                        }
                        break;
                    default:
                }
                // 用户未申请连麦 获取连麦信息
                return show(config('code.success'), '请求成功', [
                    'rtc_id' => 0,
                    'question' => '',
                    'status' => 0,
                    'tip1' => "向主播申请连线，主播会随机选择用户进行连线…",
                    'tip2' => $questionRtcNum >= 1 ? '当前' . $questionRtcNum . '人正在等待' : '',
                ]);
            } else
            {
                // 用户未申请连麦 获取连麦信息
                return show(config('code.success'), '请求成功', [
                    'rtc_id' => 0,
                    'question' => '',
                    'status' => 4,
                    'tip1' => "当前主播未开启连麦",
                    'tip2' => '',
                ]);
            }
        }
    }

    /**
     * 用户取消申请连麦
     */
    public function requestRtcDel()
    {
        $rtcId = input('rtc_id/d', 0);

        $rtcRecordModel = new LiveRtcRecord();
        $rtcInfo = $rtcRecordModel->getInfoById($rtcId);

        if ($rtcInfo && (int)$rtcInfo['uid'] !== $this->user['id'])
        {
            return show(config('code.error'), '服务异常；请稍后再试～');
        }

        if ((int)$rtcInfo['status'] === 14)
        {
            return show(config('code.success'), '取消申请成功');
        }

        if ((int)$rtcInfo['status'] !== 1)
        {
            return show(config('code.error'), '申请连麦状态变更；取消失败～');
        }

        // 更新连麦状态
        $rtcRecordModel->updateRtcInfo($rtcId, ['status' => 14, 'cancel' => $this->request->time(), 'update_time' => $this->request->time()]);
        $rtcRecordModel->rtcListDel((int)$rtcInfo['live_record_id'], $this->user['id']);    // 删除从列表中移除
        // 获取当前 rtc 开启状态
        $rtcSwitch = (int)(Cache::get("live:rtc_switch:{$rtcInfo['live_id']}:{$rtcInfo['live_record_id']}", 0));
        $liveRtcRecordModel = new LiveRtcRecord();
        $allRequestRtcUserList = $liveRtcRecordModel->getRtcUserList($rtcInfo['live_record_id']);
        unset($allRequestRtcUserList[$this->user['id']]);
        if ($allRequestRtcUserList)
        {
            $adminRtcStatus = 3;
        } else
        {
            $adminRtcStatus = $rtcSwitch;
        }

        // 向连麦用户发送消息
        LiveMessage::sendMsg(LiveMessage::who(LiveMessage::WHO_TYPE_UID, $rtcInfo['live_id'], $this->user['id'])
            , LiveMessage::MSG_TYPE_RTC_STATUS, $rtcSwitch);
        // 向直播间 管理员和主播 发送连麦 状态消息
        LiveMessage::sendMsg(LiveMessage::who(LiveMessage::WHO_TYPE_LIVER, $rtcInfo['live_id'], $rtcInfo['live_id'])
            , LiveMessage::MSG_TYPE_RTC_STATUS, $adminRtcStatus);

        return show(config('code.success'), '取消申请成功');
    }


    /**
     * 连麦问题补充
     */
    public function rtcQuestionAdd()
    {
        $rtcId = input('rtc_id/d', 0);
        $question = trim(input('question/s', ''));
        $rtcRecordModel = new LiveRtcRecord();

        if ($question == '')
        {
            return show(config('code.error'), '补充问题不能为空～');
        }

        $rtcInfo = $rtcRecordModel->getInfoById($rtcId);

        if ($rtcInfo && (int)$rtcInfo['uid'] !== $this->user['id'])
        {
            return show(config('code.error'), '服务异常；请稍后再试～');
        }

        if ($rtcInfo['status'] > 1)
        {
            return show(config('code.error'), '连麦状态更新，操作失败');
        }

        $rtcRecordModel->updateRtcInfo($rtcId, ['question' => $question]);

        return show(config('code.success'), '请求成功');
    }

    public function requestRtcInteraction()
    {
        $action = input('action/d', 0);  //  操作 1=>接受连麦 2=>拒绝连麦 3=>挂断连麦
        $liveRecordId = input('live_record_id/d', 0);

        if (!in_array($action, [1, 2, 3], true))
        {
            return show(config('code.error'), '请求异常，请稍后再试～');
        }
        $rtcRecordModel = new LiveRtcRecord();

        switch ($action)
        {
            case 1:
                $nowRtcData = $rtcRecordModel->getNowRtcDataByCache($liveRecordId);
                if (!$nowRtcData)
                {
                    return show(config('code.error'), '服务异常，连麦失败～');
                }
                if ((int)$nowRtcData['uid'] !== $this->user['id'])
                { //status  当前连麦状态 1=>邀请等待用户接受 2=>用户接受开始连麦中 3=>连麦成功 连麦中
                    return show(config('code.error'), '服务异常，请稍后再试～');
                }
                if ((int)$nowRtcData['status'] !== 1)
                {
                    return show(config('code.error'), '连线中，操作失败～');
                }

                if ((int)$nowRtcData['type'] === 1)
                {   // 用户主动 申请的连麦请求
                    $rtcRecordModel->updateRtcInfo((int)$nowRtcData['id'], [
                        'status' => 3,
                        'start_time' => $this->request->time(),
                        'update_time' => $this->request->time()
                    ]);
                } else
                {   // 主播主动 邀请的连麦请求
                    // 入库 连麦记录
                    $data = [
                        'uid' => $this->user['id'],
                        'live_id' => (int)$nowRtcData['live_id'],
                        'live_record_id' => $liveRecordId,
                        'type' => 2,
                        'status' => 3,  //连麦状态 1=>已申请待接受  2=>主播接受等待用户接听  3=>连麦中。
                        'question' => '',
                        'start_time' => $this->request->time(),
                    ];

                    $rtcId = $rtcRecordModel->addRtc($data, false);
                    $nowRtcData['id'] = $rtcId;
                }
                $nowRtcData['status'] = 2;
                $nowRtcData['network_status'] = 1;  // 网络状态 1=>正常  2=>异常
                $nowRtcData['live_network_status'] = 1; // 主播网络状态 1=>正常  2=>异常
                $nowRtcData['user_network_status'] = 1; // 用户网络状态 1=>正常  2=>异常
                $rtcRecordModel->saveNowRtcDataToCache($liveRecordId, $nowRtcData);

                $liveInfo = (new LiveAnchorInfo())->getInfoById($nowRtcData['live_id'], ['name', 'avatar']);

                // 拼接 发送给 连麦用户 数据
                $popMsgRtc2RtcUser = [
                    'type' => 1,
                    'toast' => '',
                    'user_info' => [
                        'name' => $liveInfo['name'],
                        'avatar' => $liveInfo['avatar'],
                        'uen' => $this->user['uen'],
                        'status' => 0,
                        'des_network' => '',
                    ],
                    'btn_list' => [
                        [
                            'type' => 1,
                            'title' => '挂断',
                            'target' => 'api',
                            'link' => '/api/v29/rtc_interaction?action=3&need_auth=2',
                            'mic_auth_deny' => null,
                            'action' => 2,
                        ],
                        [
                            'type' => 2,
                            'title' => '连线中…',
                            'target' => '',
                            'link' => '',
                            'mic_auth_deny' => null,
                            'action' => 0,
                        ]
                    ]
                ];
                // 拼接 发送给管理端 数据
                $popMsgRtc2Admin = [
                    'type' => 1,
                    'toast' => '',
                    'user_info' => [
                        'name' => $this->user['nickname'],
                        'avatar' => $this->user['avatar'],
                        'uen' => $this->user['uen'],
                        'status' => 0,
                        'des_network' => '',
                    ],
                    'btn_list' => [
                        [
                            'type' => 1,
                            'title' => '取消连麦',
                            'target' => 'api',
                            'link' => '/live/v2/live/request_rtc_interaction?action=4&need_auth=2',
                            'mic_auth_deny' => null,
                            'action' => 4,
                        ],
                        [
                            'type' => 2,
                            'title' => '连线中…',
                            'target' => '',
                            'link' => '',
                            'mic_auth_deny' => null,
                            'action' => 0,
                        ]
                    ]
                ];
                // 向管理员 发送消息
                LiveMessage::sendMsg(LiveMessage::who(LiveMessage::WHO_TYPE_LIVER, $nowRtcData['live_id'], $nowRtcData['live_id'])
                    , LiveMessage::MSG_TYPE_POP_MSG_RTC, $popMsgRtc2Admin);

                return show(config('code.success'), '请求成功', $popMsgRtc2RtcUser);
            case 2:
                $nowRtcData = $rtcRecordModel->getNowRtcDataByCache($liveRecordId);
                if (!$nowRtcData)
                {
                    return show(config('code.error'), '服务异常，连麦失败～');
                }
                if ((int)$nowRtcData['uid'] !== $this->user['id'])
                { //status  当前连麦状态 1=>邀请等待用户接受 2=>用户接受开始连麦中 3=>连麦成功 连麦中
                    return show(config('code.error'), '服务异常，请稍后再试～');
                }
                if ((int)$nowRtcData['status'] !== 1)
                {
                    return show(config('code.error'), '连线中，操作失败～');
                }

                if ((int)$nowRtcData['type'] === 1)
                {   // 用户主动 申请的连麦请求
                    $rtcRecordModel->updateRtcInfo((int)$nowRtcData['id'], [
                        'status' => 12,
                        'cancel' => $this->request->time(),
                        'update_time' => $this->request->time()
                    ]);

                    $rtcRecordModel->rtcListDel($liveRecordId, $this->user['id']);    // 删除从列表中移除
                }
                // 删除连线信息
                $rtcRecordModel->delNowRtcDataByCache($liveRecordId);

                // 拼接 发送给管理端 数据
                $popMsgRtc2All = [
                    'type' => 0,
                    'toast' => '',
                    'user_info' => null,
                    'btn_list' => []
                ];

                // 拼接 发送给管理端 数据
                $popMsgRtc2RtcUser = [
                    'type' => 2,
                    'toast' => '已拒绝连麦',
                    'user_info' => null,
                    'btn_list' => []
                ];

                // 拼接 发送给管理端 数据
                $popMsgRtc2Admin = [
                    'type' => 2,
                    'toast' => '当前用户拒绝连麦',
                    'user_info' => null,
                    'btn_list' => []
                ];

                // 向直播间所有人 发送消息
                LiveMessage::sendMsg(LiveMessage::who(LiveMessage::WHO_TYPE_APP_USER, $nowRtcData['live_id'], $nowRtcData['live_id'], $this->user['id'])
                    , LiveMessage::MSG_TYPE_POP_MSG_RTC, $popMsgRtc2All);

                // 向管理员 发送消息
                LiveMessage::sendMsg(LiveMessage::who(LiveMessage::WHO_TYPE_LIVER, $nowRtcData['live_id'], $nowRtcData['live_id'])
                    , LiveMessage::MSG_TYPE_POP_MSG_RTC, $popMsgRtc2Admin);

                // 获取当前 rtc 开启状态
                $rtcSwitch = (int)(Cache::get("live:rtc_switch:{$nowRtcData['live_id']}:{$liveRecordId}", 0));
                $allRequestRtcUserList = $rtcRecordModel->getRtcUserList($liveRecordId);
                if ($allRequestRtcUserList)
                {
                    $adminRtcStatus = 3;
                } else
                {
                    $adminRtcStatus = $rtcSwitch;
                }

                // 向连麦用户发送消息
                LiveMessage::sendMsg(LiveMessage::who(LiveMessage::WHO_TYPE_UID, $nowRtcData['live_id'], $this->user['id'])
                    , LiveMessage::MSG_TYPE_RTC_STATUS, $rtcSwitch);
                // 向直播间 管理员和主播 发送连麦 状态消息
                LiveMessage::sendMsg(LiveMessage::who(LiveMessage::WHO_TYPE_LIVER, $nowRtcData['live_id'], $nowRtcData['live_id'])
                    , LiveMessage::MSG_TYPE_RTC_STATUS, $adminRtcStatus);

                return show(config('code.success'), '请求成功', $popMsgRtc2RtcUser);
            case 3:
                $nowRtcData = $rtcRecordModel->getNowRtcDataByCache($liveRecordId);
                if (!$nowRtcData)
                {
                    // 拼接 发送给用户端 数据
                    $popMsgRtc2RtcUser = [
                        'type' => 2,
                        'toast' => '已挂断连麦',
                        'user_info' => null,
                        'btn_list' => []
                    ];

                    return show(config('code.success'), '操作成功', $popMsgRtc2RtcUser);
                }
                $nowRtcData['status'] = (int)$nowRtcData['status'];
                if ((int)$nowRtcData['uid'] !== $this->user['id'])
                { //status  当前连麦状态 1=>邀请等待用户接受 2=>用户接受开始连麦中 3=>连麦成功 连麦中
                    return show(config('code.error'), '服务异常，请稍后再试～');
                }
                if ($nowRtcData['status'] < 2)
                {
                    return show(config('code.error'), '连线状态异常，操作失败～');
                }

                // 挂断
                $result = (new AliyunRtc())->removeTerminals($nowRtcData['live_id'], [$this->user['id']]);
                if ($result['code'] === 200)
                {   // 挂断成功
                    $rtcRecordModel->delNowRtcDataByCache($liveRecordId); // 删除当前连麦信息

                    $questionRtcInfo = $rtcRecordModel->getInfoById($nowRtcData['id']);
                    // 计算连麦时长
                    $duration = $nowRtcData['status'] === 2 ? 0 : $this->request->time() - $questionRtcInfo['start_time'];
                    // 更新连麦记录
                    $rtcRecordModel->updateRtcInfo((int)$nowRtcData['id'], [
                        'status' => 4,
                        'duration' => $duration,
                        'cancel' => $this->request->time(),
                        'update_time' => $this->request->time()
                    ]);

                    // 列表连麦信息删除
                    if ((int)$nowRtcData['type'] === 1)
                    {
                        $rtcRecordModel->rtcListDel($liveRecordId, (int)$questionRtcInfo['uid']);    // 删除从列表中移除
                    }

                    // 拼接 发送给所有用户 数据
                    $popMsgRtc2All = [
                        'type' => 0,
                        'toast' => '',
                        'user_info' => null,
                        'btn_list' => []
                    ];

                    // 拼接 发送给用户端 数据
                    $popMsgRtc2RtcUser = [
                        'type' => 2,
                        'toast' => '已挂断连麦',
                        'user_info' => null,
                        'btn_list' => []
                    ];

                    // 拼接 发送给管理端 数据
                    $popMsgRtc2Admin = [
                        'type' => 2,
                        'toast' => '用户已挂断连麦',
                        'user_info' => null,
                        'btn_list' => []
                    ];

                    // 向直播间所有人 发送消息
                    LiveMessage::sendMsg(LiveMessage::who(LiveMessage::WHO_TYPE_APP_USER, $nowRtcData['live_id'], $nowRtcData['live_id'], $this->user['id'])
                        , LiveMessage::MSG_TYPE_POP_MSG_RTC, $popMsgRtc2All);

                    // 向管理员 发送消息
                    LiveMessage::sendMsg(LiveMessage::who(LiveMessage::WHO_TYPE_LIVER, $nowRtcData['live_id'], $nowRtcData['live_id'])
                        , LiveMessage::MSG_TYPE_POP_MSG_RTC, $popMsgRtc2Admin);

                    // 获取当前 rtc 开启状态
                    $rtcSwitch = (int)(Cache::get("live:rtc_switch:{$nowRtcData['live_id']}:{$liveRecordId}", 0));
                    $allRequestRtcUserList = $rtcRecordModel->getRtcUserList($liveRecordId);
                    if ($allRequestRtcUserList)
                    {
                        $adminRtcStatus = 3;
                    } else
                    {
                        $adminRtcStatus = $rtcSwitch;
                    }

                    // 向连麦用户发送消息
                    LiveMessage::sendMsg(LiveMessage::who(LiveMessage::WHO_TYPE_UID, $nowRtcData['live_id'], $this->user['id'])
                        , LiveMessage::MSG_TYPE_RTC_STATUS, $rtcSwitch);
                    // 向直播间 管理员和主播 发送连麦 状态消息
                    LiveMessage::sendMsg(LiveMessage::who(LiveMessage::WHO_TYPE_LIVER, $nowRtcData['live_id'], $nowRtcData['live_id'])
                        , LiveMessage::MSG_TYPE_RTC_STATUS, $adminRtcStatus);

                    return show(config('code.success'), '操作成功', $popMsgRtc2RtcUser);
                } else
                {   // TODO 提出连麦 失败异常处理
                    return show(config('code.error'), '服务异常，挂断失败');
                }
            default:
        }
        return show(config('code.error'), '请求异常，请稍后再试～');
    }
}
